<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| STORE Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$base_dir = 'App\store\controllers';

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});



//根目录
Route::group(['prefix' => '', 'namespace' => $base_dir , 'middleware' => []], function () {
    //获取用户手机号
    Route::post('/getUserPhone', 'LogonController@getUserPhone');
    //登录
    Route::post('/logon', 'LogonController@codeGetInfo');
    //忘记密码
    Route::post('/forgot_pwd', 'ForgotPasswordController@modify');
});


//工作台模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\desk' , 'middleware' => []], function () {
    Route::group(['prefix' => 'desk'],function (){
        //商户信息
        Route::get('/store_info', 'DeskController@storeInfo');
        //营业开关
        Route::get('/buss_open', 'DeskController@isOpen');
        //成交金额
        Route::get('/buss_info', 'DeskController@businessInfo');
        //交易概况
        Route::get('/overview', 'DeskController@transactionOverview');
    });
});


//商品模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\goods', 'middleware' => []], function () {
    //商品
    Route::group(['prefix' => 'goods'],function (){
        //商品列表
        Route::get('/list', ["uses" => 'GoodsController@getGoodsList']);
        //添加/编辑商品
        Route::post('/modify', ["uses" => 'GoodsController@modifyGoods']);
        //下架/删除商品
        Route::post('/removal_del', ["uses" => 'GoodsController@removalDelGoods']);
        //商品评论
        Route::any('/comment_list', ["uses" => 'CommentController@getCommentList']);

    });

    //商品分类
    Route::group(['prefix' => 'cate'],function (){
        //商品分类
        Route::get('/lists', 'CategoryController@getLists');
        //添加/编辑分类
        Route::post('/modify', 'CategoryController@categoryModify');
        //删除分类
        Route::get('/delete', 'CategoryController@categoryDelete');
        //分类信息
        Route::get('/details', 'CategoryController@categoryDetails');

    });
});

//优惠券模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\coupon' , 'middleware' => []], function () {
    //优惠券
    Route::group(['prefix' => 'coupon'],function (){
        //优惠券总量
        Route::get('/homepage', 'CouponController@couponHomePage');
        //专用券列表
        Route::get('/sc_list', 'CouponController@specialCoupon');
        //可购买引流券列表
        Route::get('/itc_list', 'CouponController@canBuyITCouponList');
        //引流券购买
        Route::post('/buy_itc', 'CouponController@buyIncreaseTrafficCoupon');
        //已有引流券总量
        Route::get('/my_itc', 'CouponController@myITCouponTotal');
        //已有引流券列表
        Route::get('/my_itc_list', 'CouponController@myITCouponList');
        //停止销售
        Route::get('/halt_sales', 'CouponController@haltSales');
        //优惠券总量
        Route::get('/total', 'CouponController@couponTotal');
        //优惠券列表
        Route::get('/lists', 'CouponController@CouponLists');
        //优惠券已使用记录
        Route::get('/use_lists', 'CouponController@usageRecord');
        //新建、编辑优惠券
        Route::post('/modify', 'CouponController@couponModify');
        //优惠券详情
        Route::get('/details', 'CouponController@couponDetails');
        //删除优惠券
        Route::get('/delete', 'CouponController@couponDelete');
    });
});

//核销模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\writeoff', 'middleware' => []], function () {
    //自提
    Route::group(['prefix' => 'selfpickup'], function () {
        //核销
        Route::group(['prefix' => 'writeoff'], function () {
            //记录
            Route::any('/record', ["uses" => 'SelfPickupController@getSelfPickupWriteoffRecord']);
            //详情
            Route::any('/details', ["uses" => 'SelfPickupController@getSelfPickupWriteoffRecordDetails']);
            //统计
            Route::any('/total', ["uses" => 'SelfPickupController@getSelfPickupWriteoffTotal']);
        });
    });
    //优惠券
    Route::group(['prefix' => 'coupon'], function () {
        //核销
        Route::group(['prefix' => 'writeoff'], function () {
            //记录
            Route::any('/record', ["uses" => 'CouponController@getCouponWriteoffRecord']);
            //详情
            Route::any('/details', ["uses" => 'CouponController@getCouponWriteoffRecordDetails']);
            //统计
            Route::any('/total', ["uses" => 'CouponController@getCouponWriteoffTotal']);
        });
    });
    //抽奖
    Route::group(['prefix' => 'draw'], function () {
        //核销
        Route::group(['prefix' => 'writeoff'], function () {
            //记录
            Route::any('/record', ["uses" => 'DrawController@getDrawWriteoffRecord']);
            //详情
            Route::any('/details', ["uses" => 'DrawController@getDrawWriteoffRecordDetails']);
            //统计
            Route::any('/total', ["uses" => 'DrawController@getDrawWriteoffTotal']);
        });
    });
    //核销人
    Route::group(['prefix' => 'writeoff'], function () {
        //核销码核销
        Route::any('/code', ["uses" => 'WriteOffController@writeoffCode']);
        //核销人
        Route::group(['prefix' => 'people'], function () {
            //列表
            Route::any('/list', ["uses" => 'WriteOffController@getWriteoffPeopleList']);
            //详情
            Route::any('/auth', ["uses" => 'WriteOffController@writeoffPeopleIsAuth']);
            //统计
            Route::any('/add', ["uses" => 'WriteOffController@addWriteoffPeople']);
        });
        //使用手机号查询用户
        Route::any('/user_list', ["uses" => 'WriteOffController@getWriteoffUserList']);
    });


});

//订单模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\orders' , 'middleware' => []], function () {
    //优惠券
    Route::group(['prefix' => 'orders'],function (){
        //订单列表
        Route::get('/lists', 'OrderController@getOrderList');
        //订单详情
        Route::get('/details', 'OrderController@getOrderDetails');
    });
});

//店铺模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\shops' , 'middleware' => []], function () {
    //店铺
    Route::group(['prefix' => 'shops'],function (){
        //店铺信息
        Route::get('/info', 'ShopController@getShopsInfo');
        //修改店铺信息
        Route::post('/update', 'ShopController@updateShopsInfo');
    });
});

//公共模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\common' , 'middleware' => []], function () {
    //公共类
    Route::group(['prefix' => 'common'],function (){
        //上传图片视频文件
        Route::post('/upload', 'UploadController@upload');
        //入驻申请
        Route::post('/settle_apply', 'SettleApplyController@settleApply');
        //工作审批流
        Route::get('/work_flow', 'workFlowController@workFlow');
    });
});

//Route::get('/hello', function () {
//    return 'world';
//});
